import time

from selenium import webdriver
class WebElementWait:
    def is_element_present(self,wd,how,what,timeout=20):
        for i in range(timeout):
            try:
                wd.find_element(how,what)
                return True
            except:
                pass
            time.sleep(0.5)
        return False

if __name__ == '__main__':
    wd=webdriver.Chrome()
    wd.get('http://www.baidu.com')
    r=WebElementWait().is_element_present(wd,'id','kw1')
    print(r)
